#include<iostream>
#include <vector>

using namespace std;

class DetectSquares {
private:
    int matrix[1001][1001];

public:
    DetectSquares() {
        memset(matrix, 0, sizeof(int) * 1001 * 1001);
    }

    void add(vector<int> point) {
        matrix[point[0]][point[1]]++;
    }

    int count(vector<int> point) {
        int count = 0;
        for (int i = -1000; i <= 1000; i++) {
            int x = point[0] + i;
            int y = point[1] + i;
            //从y开始遍历
            if (x <= 1000 && y <= 1000 && x >= 0 && y >= 0) {
                count += matrix[x][y] * matrix[x][point[1]] * matrix[point[0]][y];
            }
        }
        return count;
    }
};